Fix connection termination when using HTTP proxies#427
Conversation
When using an HTTP proxy (like v2ray), rtp2httpd was forwarding upstream response headers without ensuring Connection: close was present. This caused HTTP proxies to keep connections alive even when clients disconnected or switched channels. Changes: - Filter out Connection header from upstream responses - Always inject Connection: close in responses to clients - Add e2e tests to verify Connection: close header presence Fixes issue where connections cannot be terminated when switching channels or closing browser while using system proxy. Co-authored-by: stackia <5107241+stackia@users.noreply.github.com> Agent-Logs-Url: https://github.com/stackia/rtp2httpd/sessions/492e1c66-6b45-40a3-9efa-2f9757bb72a4
|
Closing this PR. After review, this fix targets the wrong problem and the change itself has no practical benefit. Why this doesn't fix #418Issue #418 is about an RTP multicast upstream (the reporter explicitly confirmed this in a follow-up comment). The RTP path does not go through The likely root cause of #418 lies elsewhere — most plausibly in Chrome's socket-management behavior under PAC mode, where FIN delivery for "direct" connections may be deferred. The original reporter has also been unable to reproduce since. Why injecting
|
When using HTTP proxies (e.g., v2ray), rtp2httpd forwarded upstream response headers without ensuring
Connection: closewas present, causing proxies to keep connections alive indefinitely even after clients disconnected or switched channels.Changes
Modified HTTP proxy response header handling (
src/http_proxy.c:1027-1172)Connectionheaders in both redirect and normal response pathsConnection: closeheader before sending headers to clientsAdded e2e tests (
e2e/test_http_proxy.py:500-592)Connection: closepresence in normal responsesConnection: closepresence in redirect responseskeep-aliveis correctly overridden withcloseTechnical Details
The fix modifies
http_proxy_parse_response_headers()to parse and rebuild response headers, skipping anyConnectionheader from upstream:This ensures HTTP proxies correctly terminate connections when clients disconnect, fixing the issue where switching channels or closing browsers left connections hanging.
Original prompt